import 'package:ad_plugin/ad_error.dart';
import 'package:ad_plugin/ad_listener.dart';
import 'package:ad_plugin/native_ad.dart';
import 'package:flutter/material.dart';

/// FileName native_ad_test
/// @Author zhuqingfang
/// @Date 2022/10/8 6:01 下午
/// @Description native ad test
class NativeAdTest {
  NativeAdTest._internal();

  static final NativeAdTest _instance = NativeAdTest._internal();

  factory NativeAdTest() => _instance;
  NativeAd? _nativeAd;

  void load() {
    NativeAd.load(
        placementId: 'b63414b713b112',
        width: 340,
        height: 340,
        adLoadCallback: AdLoadCallback(
            onAdLoaded: (NativeAd nativeAd) {
              debugPrint('native ad load');
              _nativeAd = nativeAd;
              _nativeAd?.contentCallback = ContentCallback(
                  onAdShow: (NativeAd nativeAd) {
                    debugPrint('banner ad onShow');
                  },
                  onAdDismiss: (NativeAd nativeAd) {
                    debugPrint('banner ad onDismiss');
                  },
                  onAdClick: (NativeAd nativeAd) {
                    debugPrint('banner ad onClick');
                  });
            },
            onAdFailLoad: (NativeAd nativeAd,LoadAdError adError) {
              debugPrint('native ad load error $adError');
            }));
  }
}
